package com.house365.im.client.receiver;

import com.house365.im.client.Constants;
import com.house365.im.client.NamespaceC;
import com.house365.im.client.dto.MessageData;
import com.house365.im.client.util.JIDUtil;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

/**
 *@Author Rick.Ping
 *@Date 2013-12-18
 *@Comment
 **/
public abstract class MessageDownloadReceiver extends BroadcastReceiver {

	@Override
	public void onReceive(Context arg0, Intent arg1) {
		// TODO Auto-generated method stub
		MessageData  data =(MessageData)arg1.getSerializableExtra(Constants.NOTIFICATION_DATA);
		if(data.getNamespace().equals(getNamespace()) || getNamespace().equals(NamespaceC.NAMESPACE_MESSAGE_ALL)){
			String s = getChater();
			if( data != null){
				if(getChater()!= null && getChater().length()>0){
					if(JIDUtil.getNameOfJID(data.getFrom()).equals(getChater())){
						dealMessage(data);
					}
				}else{
					dealMessage(data);
				}
			
				
			}
		}else{
			return;
		}
	}
	public abstract String getChater();
	public abstract void dealMessage(MessageData messageData);

	public abstract String getNamespace();
}
